package com.jerry.shop.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.jerry.shop.bean.OrderDetail;
import com.jerry.shop.enums.OrderStatusEnum;
import com.jerry.shop.enums.PayStatusEnum;
import com.jerry.shop.utils.EnumUtil;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 订单的数据传输对象
 */
@Data
//json返回数据中，如果包含null, 则不显示
//@JsonInclude(JsonInclude.Include.NON_NULL)
public class OrderDto {

    private String id;             //订单id
    private String buyerId;        //买家id
    private String buyerName;      //买家姓名
    private String buyerPhone;     //买家手机
    private String buyerAddress;   //买家地址
    private BigDecimal amount;     //订单总金额
    private Integer status;        //订单状态, 默认为0新下单
    private Integer payStatus;     //支付状态, 默认为0未支付

    List<OrderDetail> orderDetailList;      //订单中购买的商品列表

    @JsonIgnore
    public OrderStatusEnum getOrderStatusEnum() {
        return EnumUtil.getByCode(status, OrderStatusEnum.class);
    }
    @JsonIgnore
    public PayStatusEnum getPayStatusEnum() {
        return EnumUtil.getByCode(payStatus, PayStatusEnum.class);
    }

}
